<template>
	<view style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
		<!-- 标题 -->
		<!-- <text style="width: 702rpx; font-size: 34rpx;color: #333333;margin-top: 40rpx;">{{serverbox.title}}</text> -->

		<!-- 富文本 -->
		<rich-text :nodes="content" style="width: 100vw;  overflow: hidden;"></rich-text>

		<!-- 日期和浏览量 -->
		<view class="btn" style="width: 702rpx;height: 213rpx; display: flex;justify-content: space-between;margin-top: 30rpx;">
			<!-- <view>电话联系</view> -->
			<!-- pages/placeOrder carDetails订单详情  placeOrder预约下单-->
			<view class="flex justify-center r " style="width: 100vw; position: fixed; bottom: 0; left: 0;"><view @click="GO(databox)">立即预约</view></view>
			<!-- <view class="flex justify-center r " style="width: 100vw; position: fixed; bottom: 0; left: 0;"><navigator url="/pages/staff/setInfo">立即预约</navigator></view> -->
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			content: '',
			serverbox: '',
			id: '',
			type: '',

			//
			// id: '',
			databox: {},
			num: 1,
			data: {
				banner: [],
			},
			tt: '',
		};
	},
	onLoad() {
		this.id = this.$Route.query.id;
		// this.id = this.$Route.query.id;
		this.type = this.$Route.query.type;
		console.log('this.type: ', this.type);
		this.tt = this.$Route.query.tt;
		let carbox = this.databox;

		// if(this.type === 2) {
		// 	var coll = 'addons/shopro/goods/detail'
		// }else {
		// 	var coll = 'addons/shopro/Category/detail'
		// }

		var coll = 'addons/shopro/goods/detail';
		this.getCarList(coll);
	},
	methods: {
		async getCarList(coll) {
			let res;
			try {
				res = await this.$request.get(coll, {
					data: {
						id: this.id, //1是汽车，2是服务
					},
				});

				console.log(res.data.data, '================================');
				this.content = res.data.data.content
					.replace(/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/gi, '<p')
					.replace(/<p>/gi, '<p style="font-size: 15px; line-height: 25px;">')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/gi, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/gi, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/gi, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/gi, '<img$1')
					.replace(/<img([\s\w"-=\/\.:;]+)/gi, '<img style="width: 100%;" $1');
				uni.setStorageSync('carbox', res.data.data);
			} catch (e) {
				//TODO handle the exception
				console.log('e===', e);
				// return uni.showToast({
				// 	title: '网络连接失败！',
				// 	icon: 'none'
				// });
			}
			this.databox = res.data.data;
			console.log('this.databox: ', this.databox);
			this.data.banner = res.data.data.images;
		},

		// 分类
		// async getCarList() {
		// 	let res;
		// 	try {
		// 		res = await this.$request.get('addons/shopro/goods/detail', {
		// 			data: {
		// 				id: this.carid, //1是汽车，2是服务
		// 			},
		// 		});

		// 		console.log(res.data.data,'================================')
		// 		this.content = res.data.data.content;
		// 	} catch (e) {
		// 		//TODO handle the exception
		// 		console.log('e===', e);
		// 		return uni.showToast({
		// 			title: '网络连接失败！',
		// 			icon: 'none'
		// 		});
		// 	}
		// },

		GO(i) {
			i;
			// if(type === 2) {
			this.$Router.push({
				name: 'placeOrder',
				params: {
					name: i,
					id: this.id,
					tt: this.tt,
				},
			});
			// }else {
			// this.$Router.push({
			// 	name:'carDetails',
			// 	params:{
			// 		id:this.carid
			// 	}
			// })
			// }
		},
	},
};
</script>

<style lang="scss" scoped>
.btn view {
	width: 300rpx;
	font-size: 26rpx;
	height: 80rpx;
	justify-content: center;
	display: flex;
	align-items: center;
	//  border: 2rpx solid #E6E6E6;
	&:first-child {
		background: #f5f5f5;
		color: #000;
	}
	&:last-child {
		background: #4b9eff;
		color: #fff;
	}
}
</style>
